import 'package:flutter/material.dart';
import './pages/index_page.dart';

import 'package:provide/provide.dart'; //provide 状态管理
import './provide/counter.dart';
import './provide/child_category.dart'; //分类页面状态管理数据
import './provide/good_list.dart'; //分类商品状态管理
import './provide/cart.dart'; //购物车状态
import './provide/CurrentIndex.dart'; //主页面显示索引

import './provide/details_info.dart'; //详情状态管理

import 'package:fluro/fluro.dart'; //路由
import 'routers/routers.dart'; //路由配置
import 'routers/application.dart';//

void main(){
  var counter = Counter();
  var childCategory = ChildCategory();
  var categoryGoodsListProvide = CategoryGoodsListProvide();
  var detailsInfoProvide = DetailsInfoProvide();
  var cardprovide =CartProvide();
  var currentIndexProvode = CurrentIndexProvide();
  var providers = Providers();

  final router = Router();
  Routes.configureRoutes(router);
  Application.router = router;

  providers
    ..provide(Provider<Counter>.value(counter))
    ..provide(Provider<ChildCategory>.value(childCategory)) //分类列表 子导航 数据
    ..provide(Provider<CategoryGoodsListProvide>.value(categoryGoodsListProvide)) //分类商品数据
    ..provide(Provider<DetailsInfoProvide>.value(detailsInfoProvide)) //详情数据
    ..provide(Provider<CartProvide>.value(cardprovide))
    ..provide(Provider<CurrentIndexProvide>.value(currentIndexProvode))
  ;
  runApp(
    ProviderNode(
       providers: providers,
       child: MyApp(),
    )
  );
}

class MyApp extends StatelessWidget {
  const MyApp({Key key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return Container(
      child:MaterialApp(
        title: "百姓生活+",
        onGenerateRoute: Application.router.generator,
        debugShowCheckedModeBanner: false,
        theme: ThemeData(
          primarySwatch: Colors.pink
        ),
        home: IndexPage(),
      )
    );
  }
}
